﻿using RpcClient;

using RpcManageClient;

using Wedonek.RpcStore.Service.DAL;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.Collect
{
        internal class ReduceInRankCollect : BasicCollect<ReduceInRankConfigDAL>, IReduceInRankCollect
        {
                private IRpcServerCollect _RpcServer => this.GetCollect<IRpcServerCollect> ();
                public ReduceInRankConfig Get (long rpcMerId, long serverId)
                {
                        return this.BasicDAL.Get (rpcMerId, serverId);
                }
                public long GetId (long rpcMerId, long serverId)
                {
                        return this.BasicDAL.GetId (rpcMerId, serverId);
                }

                public void Sync (AddReduceInRank datum)
                {
                        long id = this.GetId (datum.RpcMerId, datum.ServerId);
                        if (id != 0)
                        {
                                ReduceInRankDatum set = datum.ConvertMap<AddReduceInRank, ReduceInRankDatum> ();
                                this.BasicDAL.Set (id, set);
                        }
                        else
                        {
                                this.BasicDAL.Add (datum);
                        }
                        this._RpcServer.RefreshReduce (datum.RpcMerId, datum.ServerId);
                }

          
                public void Drop (long id)
                {
                        this.BasicDAL.Drop (id);
                }
        }
}
